using NodeCanvas.Variables;
using UnityEngine;

namespace NodeCanvas.Actions
{
	[Name("Set Layer Weight")]
	public class MecanimSetLayerWeight : MecanimActions
	{
		public int layerIndex;

		public BBFloat layerWeight;

		[SliderField(0f, 1f)]
		public float transitTime;

		private float currentValue;

		protected override string info
		{
			get
			{
				return "Set Layer " + layerIndex + " weight " + layerWeight;
			}
		}

		protected override void OnExecute()
		{
			currentValue = base.animator.GetLayerWeight(layerIndex);
		}

		protected override void OnUpdate()
		{
			base.animator.SetLayerWeight(layerIndex, Mathf.Lerp(currentValue, layerWeight.value, base.elapsedTime / transitTime));
			if (base.elapsedTime >= transitTime)
			{
				EndAction(true);
			}
		}
	}
}
